﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PCS_Linh.lab03
{
    class FindIndex
    {
        public void run()
        {
            // nhap vao so phan tu cua mang
            Console.Write("Nhap vao so phan tu cua mang: ");
            // minh phai luu vao mot bien keiu so, nhung luc danh vao no se tra ve chuoi nen phai chuyen doi
            int n = Convert.ToInt32(Console.ReadLine());

            // khai bao mang
            int[] a = new int[n];

            for (int i = 0; i < n; i++)
            {
                Console.Write("Gia tri cua a[{0}]: " , i);
                a[i] = Convert.ToInt32(Console.ReadLine());
            }

            ////
            Console.Write("Mang la: ");
            for (int i = 0; i < n; i++)
            {
                Console.Write(a[i]+ " ");
            }
            // 1/2/4/3
            Console.Write("Nhap b: ");
            int b = Convert.ToInt32(Console.ReadLine());
            int dautien = -1;
            int cuoicung = -1;

            for (int i = 0; i < n; i++)
            {
                if (a[i] == b)
                {
                    dautien = i;
                    break;
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (a[i] == b)
                {
                    cuoicung = i;                    
                }
            }

            Console.WriteLine(dautien);
            Console.WriteLine(cuoicung);
        }
    }
}
